package com.doit.day02;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPubSub;

public class SubscribeDemo {
    public static void main(String[] args) {
        //获取到redis的对象
        Jedis redis = new Jedis("linux01", 6379);

        redis.subscribe(new JedisPubSub() {
            @Override
            public void onMessage(String channel, String message) {
                if (channel.equals("A")){
                    System.out.println("这条消息是从A渠道发来的："+message);
                }else if(channel.equals("B")){
                    System.out.println("这条消息是从B渠道发来的："+message);
                }else{
                    System.out.println("这条消息不是从AB两个渠道来的："+message);
                }
            }
        },"A","B","C");
    }
}
